package ch.fusun.baron.property;

import java.util.Map;

import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.data.DataUpdate;
import ch.fusun.baron.property.api.PropertyService;

/**
 * Update class for {@link PropertyService}
 */
public class PropertyDataUpdate implements DataUpdate {

	private Map<Object, Object> ownership;
	@Inject
	private transient PropertyService service;

	/**
	 * Injection constructor
	 */
	public PropertyDataUpdate() {

	}

	/**
	 * @param ownership
	 *            All ownership data
	 */
	public PropertyDataUpdate(Map<Object, Object> ownership) {
		this.ownership = ownership;
	}

	@Override
	public void update() {
		for (Object tile : ownership.keySet()) {
			service.setOwnership(ownership.get(tile), tile);
		}
	}

}
